home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / tree / FixedHeightLayoutCache$VisibleFHTreeStateNodeEnumeration.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  2.7 KB  |  98 lines

  1. package javax.swing.tree;
  2.  
  3. import java.util.Enumeration;
  4. import java.util.NoSuchElementException;
  5.  
  6. class FixedHeightLayoutCache$VisibleFHTreeStateNodeEnumeration implements Enumeration {
  7.    // $FF: synthetic field
  8.    private final FixedHeightLayoutCache this$0;
  9.    protected FixedHeightLayoutCache.FHTreeStateNode parent;
  10.    protected int nextIndex;
  11.    protected int childCount;
  12.  
  13.    protected FixedHeightLayoutCache$VisibleFHTreeStateNodeEnumeration(FixedHeightLayoutCache var1, FixedHeightLayoutCache.FHTreeStateNode var2) {
  14.       this(var1, var2, -1);
  15.    }
  16.  
  17.    protected FixedHeightLayoutCache$VisibleFHTreeStateNodeEnumeration(FixedHeightLayoutCache var1, FixedHeightLayoutCache.FHTreeStateNode var2, int var3) {
  18.       this.this$0 = var1;
  19.       this.parent = var2;
  20.       this.nextIndex = var3;
  21.       this.childCount = var1.treeModel.getChildCount(this.parent.getUserObject());
  22.    }
  23.  
  24.    protected boolean findNextValidParent() {
  25.       if (this.parent == FixedHeightLayoutCache.access$6(this.this$0)) {
  26.          this.parent = null;
  27.          return false;
  28.       } else {
  29.          while(this.parent != null) {
  30.             FixedHeightLayoutCache.FHTreeStateNode var1 = (FixedHeightLayoutCache.FHTreeStateNode)this.parent.getParent();
  31.             if (var1 != null) {
  32.                this.nextIndex = this.parent.childIndex;
  33.                this.parent = var1;
  34.                this.childCount = this.this$0.treeModel.getChildCount(this.parent.getUserObject());
  35.                if (this.updateNextIndex()) {
  36.                   return true;
  37.                }
  38.             } else {
  39.                this.parent = null;
  40.             }
  41.          }
  42.  
  43.          return false;
  44.       }
  45.    }
  46.  
  47.    public boolean hasMoreElements() {
  48.       return this.parent != null;
  49.    }
  50.  
  51.    public Object nextElement() {
  52.       if (!this.hasMoreElements()) {
  53.          throw new NoSuchElementException("No more visible paths");
  54.       } else {
  55.          TreePath var1;
  56.          if (this.nextIndex == -1) {
  57.             var1 = this.parent.getTreePath();
  58.          } else {
  59.             FixedHeightLayoutCache.FHTreeStateNode var2 = this.parent.getChildAtModelIndex(this.nextIndex);
  60.             if (var2 == null) {
  61.                var1 = this.parent.getTreePath().pathByAddingChild(this.this$0.treeModel.getChild(this.parent.getUserObject(), this.nextIndex));
  62.             } else {
  63.                var1 = var2.getTreePath();
  64.             }
  65.          }
  66.  
  67.          this.updateNextObject();
  68.          return var1;
  69.       }
  70.    }
  71.  
  72.    protected boolean updateNextIndex() {
  73.       if (this.nextIndex == -1 && !this.parent.isExpanded()) {
  74.          return false;
  75.       } else if (this.childCount == 0) {
  76.          return false;
  77.       } else if (++this.nextIndex >= this.childCount) {
  78.          return false;
  79.       } else {
  80.          FixedHeightLayoutCache.FHTreeStateNode var1 = this.parent.getChildAtModelIndex(this.nextIndex);
  81.          if (var1 != null && var1.isExpanded()) {
  82.             this.parent = var1;
  83.             this.nextIndex = -1;
  84.             this.childCount = this.this$0.treeModel.getChildCount(((DefaultMutableTreeNode)var1).getUserObject());
  85.          }
  86.  
  87.          return true;
  88.       }
  89.    }
  90.  
  91.    protected void updateNextObject() {
  92.       if (!this.updateNextIndex()) {
  93.          this.findNextValidParent();
  94.       }
  95.  
  96.    }
  97. }
  98.